import random
money = input("请输入金额：")
coupon =random.randint(1,10)      #优惠券
print("恭喜!抽到的商品优惠券编号是:",coupon)
minprice = 10
product = [("辣条",1),("棒棒糖",2),("方便面",5),("薯片",3),("雪糕",1),("馒头",10),("大鸡爪",8),("瓜子",4),("鸡腿",5),("啤酒",6)]
if money.isdigit():
    money = int(money)
    if money >0:
        list = []
        print("欢迎光临！")
        opinion = 1
        while opinion == 1 :
            for a, b in enumerate(product, 1):
                print("编号:", a, b)
                if minprice > product[a-1][1]:   #获取商品最低价格
                    minprice = product[a-1][1]
            choice = input("请输入商品编号：")
            if choice.isdigit():
                choice = int(choice)
            c = product[choice - 1]
            d = c[1]  # 获取商品价格
            if d > money:
                if money < minprice:
                    print("您的余额已经低于最低商品价格，购物结束！")
                    break
                else:
                    print("余额不足！剩余金额为:", round(money, 2))
            else:
                if coupon == choice:
                    money = money - d*0.8
                    list.append(c[0])
                    print("购买成功，剩余金额为",round(money,2))
                else:
                    money = money - d
                    list.append(c[0])
                    print("购买成功，剩余金额为", round(money,2))
            opinion = int(input("请问是否继续购买商品?1:继续0：不继续:"))
print("购物车内的商品为：")
for i in list:
    print(i)
print("剩余金额为：",round(money,2))

